package com.lantian.uavmaterial.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lantian.common.annotation.Log;
import com.lantian.common.core.controller.BaseController;
import com.lantian.common.core.domain.AjaxResult;
import com.lantian.common.enums.BusinessType;
import com.lantian.uavmaterial.domain.UavAirframeConstruction;
import com.lantian.uavmaterial.service.IUavAirframeConstructionService;
import com.lantian.common.utils.poi.ExcelUtil;
import com.lantian.common.core.page.TableDataInfo;

/**
 * 机身结构Controller
 * 
 * @author lantian
 * @date 2025-11-06
 */
@RestController
@RequestMapping("/uav/construction")
public class UavAirframeConstructionController extends BaseController
{
    @Autowired
    private IUavAirframeConstructionService uavAirframeConstructionService;

    /**
     * 查询机身结构列表
     */
    @PreAuthorize("@ss.hasPermi('uav:construction:list')")
    @GetMapping("/list")
    public TableDataInfo list(UavAirframeConstruction uavAirframeConstruction)
    {
        startPage();
        List<UavAirframeConstruction> list = uavAirframeConstructionService.selectUavAirframeConstructionList(uavAirframeConstruction);
        return getDataTable(list);
    }

    /**
     * 导出机身结构列表
     */
    @PreAuthorize("@ss.hasPermi('uav:construction:export')")
    @Log(title = "机身结构", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UavAirframeConstruction uavAirframeConstruction)
    {
        List<UavAirframeConstruction> list = uavAirframeConstructionService.selectUavAirframeConstructionList(uavAirframeConstruction);
        ExcelUtil<UavAirframeConstruction> util = new ExcelUtil<UavAirframeConstruction>(UavAirframeConstruction.class);
        util.exportExcel(response, list, "机身结构数据");
    }

    /**
     * 获取机身结构详细信息
     */
    @PreAuthorize("@ss.hasPermi('uav:construction:query')")
    @GetMapping(value = "/{airframeStructureId}")
    public AjaxResult getInfo(@PathVariable("airframeStructureId") String airframeStructureId)
    {
        return success(uavAirframeConstructionService.selectUavAirframeConstructionByAirframeStructureId(airframeStructureId));
    }

    /**
     * 新增机身结构
     */
    @PreAuthorize("@ss.hasPermi('uav:construction:add')")
    @Log(title = "机身结构", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UavAirframeConstruction uavAirframeConstruction)
    {
        return toAjax(uavAirframeConstructionService.insertUavAirframeConstruction(uavAirframeConstruction));
    }

    /**
     * 修改机身结构
     */
    @PreAuthorize("@ss.hasPermi('uav:construction:edit')")
    @Log(title = "机身结构", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UavAirframeConstruction uavAirframeConstruction)
    {
        return toAjax(uavAirframeConstructionService.updateUavAirframeConstruction(uavAirframeConstruction));
    }

    /**
     * 删除机身结构
     */
    @PreAuthorize("@ss.hasPermi('uav:construction:remove')")
    @Log(title = "机身结构", businessType = BusinessType.DELETE)
	@DeleteMapping("/{airframeStructureIds}")
    public AjaxResult remove(@PathVariable String[] airframeStructureIds)
    {
        return toAjax(uavAirframeConstructionService.deleteUavAirframeConstructionByAirframeStructureIds(airframeStructureIds));
    }
}
